/* eslint-disable indent */
/* eslint-disable prefer-const */
const readline = require('readline')

/*
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})

rl.question('你如何看待 Node.js 中文网？', (answer) => {
  // TODO：将答案记录在数据库中。
  console.log(`感谢您的宝贵意见：${answer}`)
  rl.close()
})
 */
// while (true) {
//   var num = parseInt(readline())
//   if (num === 0) {
//     break
//   }
//   var lines = readline()
//   var lineArr = lines.split(' ').map(Number)
//   var type = lineArr[0]
//   var money = lineArr.slice(1)
//   console.log(getResult(num, type, money))
// }

// function getResult (num, type, money) {
//   var dp = []
//   dp[0] = 0
//   for (var i = 1; i <= num; i++) {
//     var arr = []
//     for (var j = 0; j < money.length; j++) {
//       if (i >= money[j]) {
//         arr.push(dp[i - money[j]] + 1)
//       }
//     }
//     dp[i] = Math.min(...arr)
//   }
//   return dp[num] === Infinity ? 'Impossible' : dp[num]
// }
// const readline = require('readline')
const rl = readline.createInterface({
  input: process.stdin,
  ouput: process.stdout
})
let inArr = []
rl.on('line', line => {
    if (!line) return
    inArr.push(line.trim())
    // rl.close()
    if (inArr[inArr.length - 1] === 0) {
        for (let i = 0; i < inArr.length - 2; i += 2) {
            let amount = +inArr[i]
            let coins = inArr[i + 1].split(' ').map(e => +e)
            console.log(coinChange(coins, amount))
        }
    }
})

var coinChange = function (coins, amount) {
    let dp = new Array(amount + 1).fill(Infinity)
    dp[0] = 0
    for (let coin of coins) {
        for (let i = 1; i <= amount; i++) {
            if (i - coin >= 0) {
                dp[i] = Math.min(dp[i], dp[i - coin] + 1)
            }
        }
    }
    return dp[amount] === Infinity ? 'Impossible' : dp[amount]
}
